package 剑指offer;

/**
 * @description:
 * @author: ywk
 * @date: 2021-04-11
 */
public class 顺时针旋转矩阵 {
    public static int[][] rotateMatrix(int[][] mat, int n) {
        // write code here
        int[][] copy = new int[mat.length][mat[0].length];
        int col = 0;
        for (int i = mat.length - 1; i >= 0; i--) {
            int row = 0;
            for (int j = 0; j < mat[0].length; j++) {
                copy[row++][col] = mat[i][j];

            }
            col++;
        }
        return copy;
    }

    public static void main(String[] args) {
        rotateMatrix(new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, 3);
    }
}
